package com.ruoyi.property.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.property.domain.FeeImport;
import com.ruoyi.property.service.IFeeImportService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 费用导入Controller
 * 
 * @author sux
 * @date 2021-06-30
 */
@Controller
@RequestMapping("/property/feeImport")
public class FeeImportController extends BaseController
{
    private String prefix = "property/feeImport";

    @Autowired
    private IFeeImportService feeImportService;

    @RequiresPermissions("property:feeImport:view")
    @GetMapping()
    public String feeImport()
    {
        return prefix + "/feeImport";
    }

    /**
     * 查询费用导入列表
     */
    @RequiresPermissions("property:feeImport:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(FeeImport feeImport)
    {
        startPage();
        List<FeeImport> list = feeImportService.selectFeeImportList(feeImport);
        return getDataTable(list);
    }

    /**
     * 导出费用导入列表
     */
    @RequiresPermissions("property:feeImport:export")
    @Log(title = "费用导入", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FeeImport feeImport)
    {
        List<FeeImport> list = feeImportService.selectFeeImportList(feeImport);
        ExcelUtil<FeeImport> util = new ExcelUtil<FeeImport>(FeeImport.class);
        return util.exportExcel(list, "feeImport");
    }

    /**
     * 新增费用导入
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存费用导入
     */
    @RequiresPermissions("property:feeImport:add")
    @Log(title = "费用导入", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(FeeImport feeImport)
    {
        return toAjax(feeImportService.insertFeeImport(feeImport));
    }

    /**
     * 修改费用导入
     */
    @GetMapping("/edit/{importFeeId}")
    public String edit(@PathVariable("importFeeId") Long importFeeId, ModelMap mmap)
    {
        FeeImport feeImport = feeImportService.selectFeeImportById(importFeeId);
        mmap.put("feeImport", feeImport);
        return prefix + "/edit";
    }

    /**
     * 修改保存费用导入
     */
    @RequiresPermissions("property:feeImport:edit")
    @Log(title = "费用导入", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(FeeImport feeImport)
    {
        return toAjax(feeImportService.updateFeeImport(feeImport));
    }

    /**
     * 删除费用导入
     */
    @RequiresPermissions("property:feeImport:remove")
    @Log(title = "费用导入", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(feeImportService.deleteFeeImportByIds(ids));
    }
}
